{% extends "base.html" %}

{% block title %}
boxFilter
{% endblock %}

{% block description %}
<p>Blurs an image using the box filter. </p>
{% endblock %}

{% block signature %}
<pre>cv2.boxFilter(src, ddepth, ksize[, dst[, anchor[, normalize[, borderType]]]])  &rarr; dst</pre>
{% endblock %}

{% block parameters %}
<ul>
    <li><prmtr>src</prmtr> (<ptype>np.ndarray</ptype>): Input image. The image can have any number of channels, which are processed independently.</li>
    <li><prmtr>ddepth</prmtr> (<a href="https://docs.opencv.org/master/d4/d86/group__imgproc__filter.html#filter_depths"><code>cv2.CV_*</code></a>): Output image depth. Default is -1 to use <code>src1.depth()</code>, and this is used in this app.</li>
    <li><prmtr>ksize</prmtr> (<ptype>tuple: (int, int)</ptype>): Blurring kernel size.</li>
    <li><prmtr>dst</prmtr> (optional; <ptype>np.ndarray</ptype>): Output image of the same size and number of channels as <code>src</code>. </li>
    <li><prmtr>anchor</prmtr> (optional; <ptype>tuple: (int, int)</ptype>): Anchor point; default value (-1, -1) means that the anchor is at the kernel center. The tuple represents (column, row) rather than (row, column).</li>
    <li><prmtr>normalize</prmtr> (optional; <ptype>bool</ptype>): Specifies whether the kernel is normalized by its area or not. True is the default.</li>
    <li><prmtr>borderType</prmtr> (optional; <a href="https://docs.opencv.org/master/d2/de8/group__core__array.html#ga209f2f4869e304c82d07739337eae7c5"><code>cv2.BORDER_*</code></a>): Pixel extrapolation method. Default is BORDER_DEFAULT. One of the following: 
	<ul>
        <li>BORDER_CONSTANT</li>
        <li>BORDER_REPLICATE</li>
        <li>BORDER_REFLECT</li>
        <li>BORDER_REFLECT_101 or BORDER_REFLECT101 or BORDER_DEFAULT</li>
        <li>BORDER_ISOLATED</li>
    </ul> </li>
</ul>
{% endblock %}

{% block notes %}
<ul>
    <li>Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms, and so on). If you need to compute pixel sums over variable-size windows, use integral().</li>
    
    <li>In frequency domain analysis of the image, this filter is a low pass filter. The frequency domain analysis is done using Fourier transformation of the image (<a href="https://hub.packtpub.com/image-filtering-techniques-opencv/">Source</a>). </li>
    <li>The larger the kernel matrix, the blurrier the resulting image. This is due to averaging out of peak values in small neighbourhood where the kernel is applied.  In most applications, kernel size is heuristically set according to image size (<a href="https://hub.packtpub.com/image-filtering-techniques-opencv/">Source</a>).  </li>
    <li>BORDER_WRAP and BORDER TRANSPARENT are not supported for <code>borderType</code>.</li>
    <li>If you want to use BORDER_CONSTANT, you should manually add border to your image with <code>copyMakeBorder</code>, otherwise the default value is set to 0.</li>
</ul>
{% endblock %}

{% block explanation %}
<p>
    The function smoothes an image using the kernel: 

    $$K = \alpha \left[\begin{matrix}1&1&1&...&1&1\\1&1&1&...&1&1\\...\\1&1&1&...&1&1\\\end{matrix}\right]$$
    
    where

    $$\alpha = \begin{cases}
    \frac{1}{ksize.width\ast ksize.height},& \text{when } \texttt{normalize=True};\\
    1,              & \text{otherwise.}
    \end{cases}$$
</p>
{% endblock %}

{% block references %}
<ul>
    <li><a  href="https://docs.opencv.org/master/d4/d86/group__imgproc__filter.html#gad533230ebf2d42509547d514f7d3fbc3">OpenCV Documentation</a></li>
    <li><a href="https://hub.packtpub.com/image-filtering-techniques-opencv/">BoxFilter Information</a></li>
</ul>
{% endblock %}